package com.ruoyi.statistic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistic.domain.WMonthEnterWarehouseStat;
import com.ruoyi.statistic.service.IWMonthEnterWarehouseStatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 月入库量Controller
 * 
 * @author wzy
 * @date 2024-09-01 18:17:47
 */
@RestController
@RequestMapping("/statistic/monthenter")
public class WMonthEnterWarehouseStatController extends BaseController
{
    @Autowired
    private IWMonthEnterWarehouseStatService wMonthEnterWarehouseStatService;

    /**
     * 查询月入库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:list')")
    @GetMapping("/list")
    public TableDataInfo list(WMonthEnterWarehouseStat wMonthEnterWarehouseStat)
    {
        startPage();
        List<WMonthEnterWarehouseStat> list = wMonthEnterWarehouseStatService.selectWMonthEnterWarehouseStatList(wMonthEnterWarehouseStat);
        return getDataTable(list);
    }

    /**
     * 导出月入库量列表
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:export')")
    @Log(title = "月入库量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WMonthEnterWarehouseStat wMonthEnterWarehouseStat)
    {
        List<WMonthEnterWarehouseStat> list = wMonthEnterWarehouseStatService.selectWMonthEnterWarehouseStatList(wMonthEnterWarehouseStat);
        ExcelUtil<WMonthEnterWarehouseStat> util = new ExcelUtil<WMonthEnterWarehouseStat>(WMonthEnterWarehouseStat.class);
        util.exportExcel(response, list, "月入库量数据");
    }

    /**
     * 获取月入库量详细信息
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:query')")
    @GetMapping(value = "/{monthEnterStatisticId}")
    public AjaxResult getInfo(@PathVariable("monthEnterStatisticId") Long monthEnterStatisticId)
    {
        return success(wMonthEnterWarehouseStatService.selectWMonthEnterWarehouseStatByMonthEnterStatisticId(monthEnterStatisticId));
    }

    /**
     * 新增月入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:add')")
    @Log(title = "月入库量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WMonthEnterWarehouseStat wMonthEnterWarehouseStat)
    {
        wMonthEnterWarehouseStat.setCreateBy(getNickName());
        return toAjax(wMonthEnterWarehouseStatService.insertWMonthEnterWarehouseStat(wMonthEnterWarehouseStat));
    }

    /**
     * 修改月入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:edit')")
    @Log(title = "月入库量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WMonthEnterWarehouseStat wMonthEnterWarehouseStat)
    {
        wMonthEnterWarehouseStat.setUpdateBy(getNickName());
        return toAjax(wMonthEnterWarehouseStatService.updateWMonthEnterWarehouseStat(wMonthEnterWarehouseStat));
    }

    /**
     * 删除月入库量
     */
    @PreAuthorize("@ss.hasPermi('statistic:monthenter:remove')")
    @Log(title = "月入库量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{monthEnterStatisticIds}")
    public AjaxResult remove(@PathVariable Long[] monthEnterStatisticIds)
    {
        return toAjax(wMonthEnterWarehouseStatService.deleteWMonthEnterWarehouseStatByMonthEnterStatisticIds(monthEnterStatisticIds));
    }
}
